package com.itheima.health.controller;

import com.itheima.health.common.MessageConst;
import com.itheima.health.entity.Result;
import com.itheima.health.pojo.Setmeal;
import com.itheima.health.service.SetMealService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author ：石破天
 * @date ：Created in 2022年06月07日
 * @description ：
 * @version: 1.0
 */
@RestController
@RequestMapping("/mobile/setmeal")
@Slf4j
@Api(tags = "手机端套餐接口")
public class MobileSetMealController {
    @Autowired
    private SetMealService setMealService;

    /**
     * 任务7 体检预约-全部套餐查询
     */
    @GetMapping("/getSetmeal")
    public Result getSetmeal() {
        log.info("getSetmeal运行");
        List<Setmeal> setmeals = setMealService.getSetmeal();
        return new Result(true, MessageConst.QUERY_SETMEALLIST_SUCCESS, setmeals);
    }

    /**
     * 体检预约功能-套餐详情
     * @param id 查询套餐的id
     * @return 返回查询结果 -- 详情
     */
    @GetMapping("/findById")
    public Result findById(int id) {

        // 定义方法,查询所有信息
        Setmeal setmeal = setMealService.selectAllById(id);

        // 返回查询到的数据给前端
        return new Result(true, MessageConst.QUERY_SETMEALLIST_SUCCESS, setmeal);
    }
}
